"""
    pymysql

    pip install pymysql -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

    https://pypi.org/project/PyMySQL/
"""
import pymysql

connection = pymysql.connect(host='localhost',
                             user='root',
                             password='123456',
                             database='db_16',
                             port=3306)
# connection.autocommit(True)
# 游标
cursor = connection.cursor()

# sql = "select * from test"
# 执行sql
# cursor.execute(sql)
# 获取
# result = cursor.fetchall()
# result = cursor.fetchone() # 取一条数据
# result = cursor.fetchmany(1000) # 取多条数据
# for res in result:
#     print(res[0])
#     print(res[1])
#     print(res[2])

# sql = "select * from test where DE084= %s and DE011= %s"
# cursor.execute(sql, args=(206, 2012))
# result = cursor.fetchall()
# print(result)


# sql = "insert into test values(%s,%s,%s)"
# cursor.execute(sql, args=(1, 1, 1))
# connection.commit()

# sql = "update test set DE084=%s where DE011= %s "
# cursor.execute(sql, args=(209, 2012))
# connection.commit()

# sql = "delete from test where DE084=%s"
# cursor.execute(sql, args=(1,))
# connection.commit()


sql = "insert into test values(%s,%s,%s)"
cursor.executemany(sql, [(1,1,1),(2,2,2)])
connection.commit()